package biz.ezcom.design.pattern.strategy;

public class Context {
	
	
	private Strategy strategy;

	public Context(String type) {
		if(Strategy.NOMARL.equals(type)){
			strategy = new StrategyNormal();//正常不打折
		}else if(Strategy.REBATE.equals(type)){
			strategy = new StrategyRebate(0.8d);//打８折
		}else if(Strategy.RETURN.equals(type)){
			strategy = new StrategyReturn(300, 100);//满300返100
		}else{
			throw new RuntimeException("没有这种打折策略");
		}
	}
	
	public double getResultCash(double cash){
		return strategy.getResult(cash);
	}
	
}
